package xyz.zcq.zcqrpc.server;

import io.vertx.core.Vertx;

/**
 * Vertx HTTP 服务器
 */
public class VertxHttpServer implements HttpServer {

    @Override
    public void doStart(int port) {
        // 创建Http服务器实例
        io.vertx.core.http.HttpServer httpServer = Vertx.vertx().createHttpServer();

        // 请求处理
        httpServer.requestHandler(new HttpServerHandler());

        // 指定监听端口，启动服务器
        httpServer.listen(port, asyncResult -> {
            if (asyncResult.succeeded()) {
                System.out.println("Server is now listening on port " + port);
            } else {
                System.err.println("Failed to start server: " + asyncResult.cause());
            }
        });
    }

}
